import { ref } from 'vue'
import { useColumnStore } from '@/stores/columnStore'
import { storeToRefs } from 'pinia'
import { useCardStore } from '@/stores/cardStore'
import { useAsyncAxios } from '@/utils/asyncFuncStore'
import { useModalStore } from '@/stores/modalStore'
import { useRouter } from 'vue-router'
import { useMainIndexStore } from '@/stores/mainIndexStore'
import type { ColumnsList, CardData } from '@/types/loginType'

export default function () {
  const { listData } = storeToRefs(useColumnStore())
  const isSelected = ref('')
  const router = useRouter()

  async function clicked(item: ColumnsList) {
    isSelected.value = item.id
    // 路由跳转
    const { assignTitle } = useMainIndexStore()
    assignTitle({ msg: item.name, img: item.img })
    router.push({ name: 'columns', query: { key: item.id } })
  }

  return {
    listData,
    isSelected,
    clicked
  }
}
